import axios from '../axios';

/** *********获取天添金产品详情******** */
export const getQrpProducts = (stockCode) => axios.post('dz-mall/qrp/getProducts', {
  stockCode
});

/** *********获取用户可报价回购金额******** */
export const getQrpBalance = () => axios.post('dz-mall/qrp/getQrpEnableBalance');

/** *********获取天添金购买记录数据******** */
export const getQrpHistoryList = (dayNum = 7) => axios.post('dz-mall/qrp/getMyQrpHistoryList', {
  dayNum
});

/** *********获取用户一个月收益、累计收益******** */
export const getUserProfit = () => axios.post('dz-mall/qrp/getUserProfit');

/** *********获取天添金报价回购当日委托查询******** */
export const getMyPurchaseToday = () => axios.post('dz-mall/qrp/getMyPurchaseToday');

/** *********获取天添金未到期报价回购委托查询（持仓）******** */
export const getMyPurchaseUndue = () => axios.post('dz-mall/qrp/getMyPurchaseUndue');

/** *********获取天添金报价回购历史委托记录（废弃）******** */
export const getMyPurchaseHistory = (dayNum = 7) => axios.post('dz-mall/qrp/getMyPurchaseHistory', {
  dayNum
});

/** *********获取天添金报价回购历史委托记录******** */
export const getQrpProductElig = () => axios.post('dz-mall/qrp/checkInadequacy');

/** *********操作天添金购买订单******** */
export const doQrpOperation = (params) => axios.post('dz-mall/qrp/doOperationPurchase', {
  operation: params.operation, // 必须，操作类型，cd撤单，tqgh提前购回,yytqgh预约提前购回...
  entrustNo: params.entrustNo,
  serialNo: params.serialNo,
  entrustDate: params.entrustDate,
  stockCode: params.stockCode
});

/** *********获取天添金购买记录数据******** */
export const doQrpBuy = (params) => axios.post('dz-mall/qrp/buy', {
  stockCode: params.stockCode,
  postponeFlag: params.postponeFlag,
  investAmount: params.investAmount,
  orderChannel: params.orderChannel
});

/** *********判断是否开通K权限******** */
export const checkKRight = () => axios.post('dz-mall/qrp/checkKRight');

/** *********开通K权限******** */
export const openKRight = (channel) => axios.post('dz-mall/qrp/openKRight', {
  channel
});

/** *********“天添金-新客享”检查是否有抽奖获得的资格******** */
export const checkClientWfQualification = () => axios.post('dz-mall/qrp/checkClientWfQualification');

/** *********“天添金-新客享”产品是否满足开户条件******** */
export const isNewClientForSpecQrp = () => axios.post('dz-mall/qrp/isNewClientForSpecQrp');

/** *********“天添金-新客享”产品是否已购买******** */
export const isAlreadyBuySpecQrp = () => axios.post('dz-mall/qrp/isUserAlreadyBuySpecQrp');

/** *********“天添金-新客享”获取活动产品详情******** */
export const getSpecQrpProduct = () => axios.post('dz-mall/qrp/getSpecQrpProduct');

/** *********“天添金-新客享”参与预售确认******** */
export const buySpecQrp = (paras) => axios.post('dz-mall/qrp/buySpecQrp', {
  stockCode: paras.stockCode,
  amount: paras.amount,
  orderChannel: paras.orderChannel,
  salesChannel: paras.channelId
});

/** *********“天添金-新客享”获取所有订单******** */
export const revokeSpecQrp = (orderId) => axios.post('dz-mall/qrp/revokeOrder', {
  orderId
});

/** *********“天添金-新客享”获取所有订单******** */
export const getSpecQrpOrderHistory = (dayNum = 0) => axios.post('dz-mall/qrp/getSpecQrpOrderHistory', {
  dayNum
});

/** *********“天添金”协议本地数据库留痕******** */
export const signQrpAgreement = (params) => axios.post('dz-mall/qrp/signAgreement', {
  stockCode: params.stockCode,
  content: params.content
});
